<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-pragma">{-# OPTIONS_GHC -optc-DWINVER=0x0600 #-}</span><span>
</span><span id="line-2"></span><span class="hs-pragma">{-# OPTIONS_GHC -optc-D_WIN32_WINNT=0x0600 #-}</span><span>
</span><span id="line-3"></span><span class="hs-pragma">{-# LINE 1 &quot;libraries\\Win32\\System\\Win32\\MinTTY.hsc&quot; #-}</span><span>
</span><span id="line-1"></span><span class="hs-pragma">{-# LANGUAGE ScopedTypeVariables #-}</span><span>
</span><span id="line-2"></span><span>
</span><span id="line-3"></span><span>
</span><span id="line-4"></span><span class="hs-pragma">{-# LINE 4 &quot;libraries\\Win32\\System\\Win32\\MinTTY.hsc&quot; #-}</span><span>
</span><span id="line-4"></span><span class="hs-pragma">{-# LANGUAGE Safe #-}</span><span>
</span><span id="line-5"></span><span>
</span><span id="line-6"></span><span class="hs-pragma">{-# LINE 8 &quot;libraries\\Win32\\System\\Win32\\MinTTY.hsc&quot; #-}</span><span>
</span><span id="line-8"></span><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-9"></span><span class="hs-comment">-- |</span><span>
</span><span id="line-10"></span><span class="hs-comment">-- Module      :  System.Win32.MinTTY</span><span>
</span><span id="line-11"></span><span class="hs-comment">-- Copyright   :  (c) University of Glasgow 2006</span><span>
</span><span id="line-12"></span><span class="hs-comment">-- License     :  BSD-style (see the file LICENSE)</span><span>
</span><span id="line-13"></span><span class="hs-comment">--</span><span>
</span><span id="line-14"></span><span class="hs-comment">-- Maintainer  :  Esa Ilari Vuokko &lt;ei@vuokko.info&gt;</span><span>
</span><span id="line-15"></span><span class="hs-comment">-- Stability   :  provisional</span><span>
</span><span id="line-16"></span><span class="hs-comment">-- Portability :  portable</span><span>
</span><span id="line-17"></span><span class="hs-comment">--</span><span>
</span><span id="line-18"></span><span class="hs-comment">-- A function to check if the current terminal uses MinTTY.</span><span>
</span><span id="line-19"></span><span class="hs-comment">-- Much of this code was originally authored by Phil Ruffwind and the</span><span>
</span><span id="line-20"></span><span class="hs-comment">-- git-for-windows project.</span><span>
</span><span id="line-21"></span><span class="hs-comment">--</span><span>
</span><span id="line-22"></span><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-23"></span><span>
</span><span id="line-24"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">System.Win32.MinTTY</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">isMinTTY</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">isMinTTYHandle</span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-25"></span><span>
</span><span id="line-26"></span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">Graphics.Win32.Misc</span><span>
</span><span id="line-27"></span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">System.Win32.DLL</span><span>
</span><span id="line-28"></span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">System.Win32.File</span><span>
</span><span id="line-29"></span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">System.Win32.Types</span><span>
</span><span id="line-30"></span><span>
</span><span id="line-31"></span><span>
</span><span id="line-32"></span><span class="hs-pragma">{-# LINE 32 &quot;libraries\\Win32\\System\\Win32\\MinTTY.hsc&quot; #-}</span><span>
</span><span id="line-32"></span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">Control.Exception</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">catch</span><span class="hs-special">)</span><span>
</span><span id="line-33"></span><span>
</span><span id="line-34"></span><span class="hs-pragma">{-# LINE 34 &quot;libraries\\Win32\\System\\Win32\\MinTTY.hsc&quot; #-}</span><span>
</span><span id="line-34"></span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">Data.List</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">isPrefixOf</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">isInfixOf</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">isSuffixOf</span><span class="hs-special">)</span><span>
</span><span id="line-35"></span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">Foreign</span><span>
</span><span id="line-36"></span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">Foreign.C.Types</span><span>
</span><span id="line-37"></span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">System.FilePath</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">takeFileName</span><span class="hs-special">)</span><span>
</span><span id="line-38"></span><span>
</span><span id="line-39"></span><span>
</span><span id="line-40"></span><span class="hs-pragma">{-# LINE 42 &quot;libraries\\Win32\\System\\Win32\\MinTTY.hsc&quot; #-}</span><span>
</span><span id="line-42"></span><span>
</span><span id="line-43"></span><span class="hs-comment">-- The headers that are shipped with GHC's copy of MinGW-w64 assume Windows XP.</span><span>
</span><span id="line-44"></span><span class="hs-comment">-- Since we need some structs that are only available with Vista or later,</span><span>
</span><span id="line-45"></span><span class="hs-comment">-- we must manually set WINVER/_WIN32_WINNT accordingly.</span><span class="hs-cpp">




#include &quot;windows_cconv.h&quot;
</span><span>
</span><span id="line-52"></span><span>
</span><span id="line-53"></span><span>
</span><span id="line-54"></span><span class="hs-comment">-- | Returns 'True' if the current process's standard error is attached to a</span><span>
</span><span id="line-55"></span><span class="hs-comment">-- MinTTY console (e.g., Cygwin or MSYS). Returns 'False' otherwise.</span><span>
</span><span id="line-56"></span><span class="hs-identifier">isMinTTY</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">Bool</span><span>
</span><span id="line-57"></span><span class="hs-identifier">isMinTTY</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-58"></span><span>    </span><span class="hs-identifier">h</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-identifier">getStdHandle</span><span> </span><span class="hs-identifier">sTD_ERROR_HANDLE</span><span>
</span><span id="line-59"></span><span>           </span><span class="hs-special">`</span><span class="hs-identifier">catch</span><span class="hs-special">`</span><span> </span><span class="hs-glyph">\</span><span class="hs-special">(</span><span class="hs-identifier">_</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">IOError</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-60"></span><span>             </span><span class="hs-identifier">return</span><span> </span><span class="hs-identifier">nullHANDLE</span><span>
</span><span id="line-61"></span><span>    </span><span class="hs-keyword">if</span><span> </span><span class="hs-identifier">h</span><span> </span><span class="hs-operator">==</span><span> </span><span class="hs-identifier">nullHANDLE</span><span>
</span><span id="line-62"></span><span>       </span><span class="hs-keyword">then</span><span> </span><span class="hs-identifier">return</span><span> </span><span class="hs-identifier">False</span><span>
</span><span id="line-63"></span><span>       </span><span class="hs-keyword">else</span><span> </span><span class="hs-identifier">isMinTTYHandle</span><span> </span><span class="hs-identifier">h</span><span>
</span><span id="line-64"></span><span>
</span><span id="line-65"></span><span class="hs-comment">-- | Returns 'True' is the given handle is attached to a MinTTY console</span><span>
</span><span id="line-66"></span><span class="hs-comment">-- (e.g., Cygwin or MSYS). Returns 'False' otherwise.</span><span>
</span><span id="line-67"></span><span class="hs-identifier">isMinTTYHandle</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">HANDLE</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">Bool</span><span>
</span><span id="line-68"></span><span class="hs-identifier">isMinTTYHandle</span><span> </span><span class="hs-identifier">h</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-69"></span><span>    </span><span class="hs-identifier">fileType</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-identifier">getFileType</span><span> </span><span class="hs-identifier">h</span><span>
</span><span id="line-70"></span><span>    </span><span class="hs-keyword">if</span><span> </span><span class="hs-identifier">fileType</span><span> </span><span class="hs-operator">/=</span><span> </span><span class="hs-identifier">fILE_TYPE_PIPE</span><span>
</span><span id="line-71"></span><span>      </span><span class="hs-keyword">then</span><span> </span><span class="hs-identifier">return</span><span> </span><span class="hs-identifier">False</span><span>
</span><span id="line-72"></span><span>      </span><span class="hs-keyword">else</span><span> </span><span class="hs-identifier">isMinTTYVista</span><span> </span><span class="hs-identifier">h</span><span> </span><span class="hs-special">`</span><span class="hs-identifier">catch</span><span class="hs-special">`</span><span> </span><span class="hs-glyph">\</span><span class="hs-special">(</span><span class="hs-identifier">_</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">IOError</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">isMinTTYCompat</span><span> </span><span class="hs-identifier">h</span><span>
</span><span id="line-73"></span><span>      </span><span class="hs-comment">-- GetFileNameByHandleEx is only available on Vista and later (hence</span><span>
</span><span id="line-74"></span><span>      </span><span class="hs-comment">-- the name isMinTTYVista). If we're on an older version of Windows,</span><span>
</span><span id="line-75"></span><span>      </span><span class="hs-comment">-- getProcAddress will throw an IOException when it fails to find</span><span>
</span><span id="line-76"></span><span>      </span><span class="hs-comment">-- GetFileNameByHandleEx, and thus we will default to using</span><span>
</span><span id="line-77"></span><span>      </span><span class="hs-comment">-- NtQueryObject (isMinTTYCompat).</span><span>
</span><span id="line-78"></span><span>
</span><span id="line-79"></span><span class="hs-identifier">isMinTTYVista</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">HANDLE</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">Bool</span><span>
</span><span id="line-80"></span><span class="hs-identifier">isMinTTYVista</span><span> </span><span class="hs-identifier">h</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-81"></span><span>    </span><span class="hs-identifier">fn</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-identifier">getFileNameByHandle</span><span> </span><span class="hs-identifier">h</span><span>
</span><span id="line-82"></span><span>    </span><span class="hs-identifier">return</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">cygwinMSYSCheck</span><span> </span><span class="hs-identifier">fn</span><span>
</span><span id="line-83"></span><span>  </span><span class="hs-special">`</span><span class="hs-identifier">catch</span><span class="hs-special">`</span><span> </span><span class="hs-glyph">\</span><span class="hs-special">(</span><span class="hs-identifier">_</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">IOError</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-84"></span><span>    </span><span class="hs-identifier">return</span><span> </span><span class="hs-identifier">False</span><span>
</span><span id="line-85"></span><span>
</span><span id="line-86"></span><span class="hs-identifier">isMinTTYCompat</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">HANDLE</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">Bool</span><span>
</span><span id="line-87"></span><span class="hs-identifier">isMinTTYCompat</span><span> </span><span class="hs-identifier">h</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-88"></span><span>    </span><span class="hs-identifier">fn</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-identifier">ntQueryObjectNameInformation</span><span> </span><span class="hs-identifier">h</span><span>
</span><span id="line-89"></span><span>    </span><span class="hs-identifier">return</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">cygwinMSYSCheck</span><span> </span><span class="hs-identifier">fn</span><span>
</span><span id="line-90"></span><span>  </span><span class="hs-special">`</span><span class="hs-identifier">catch</span><span class="hs-special">`</span><span> </span><span class="hs-glyph">\</span><span class="hs-special">(</span><span class="hs-identifier">_</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">IOError</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-91"></span><span>    </span><span class="hs-identifier">return</span><span> </span><span class="hs-identifier">False</span><span>
</span><span id="line-92"></span><span>
</span><span id="line-93"></span><span class="hs-identifier">cygwinMSYSCheck</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">String</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Bool</span><span>
</span><span id="line-94"></span><span class="hs-identifier">cygwinMSYSCheck</span><span> </span><span class="hs-identifier">fn</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="hs-string">&quot;cygwin-&quot;</span><span> </span><span class="hs-special">`</span><span class="hs-identifier">isPrefixOf</span><span class="hs-special">`</span><span> </span><span class="hs-identifier">fn'</span><span> </span><span class="hs-operator">||</span><span> </span><span class="hs-string">&quot;msys-&quot;</span><span> </span><span class="hs-special">`</span><span class="hs-identifier">isPrefixOf</span><span class="hs-special">`</span><span> </span><span class="hs-identifier">fn'</span><span class="hs-special">)</span><span> </span><span class="hs-operator">&amp;&amp;</span><span>
</span><span id="line-95"></span><span>            </span><span class="hs-string">&quot;-pty&quot;</span><span> </span><span class="hs-special">`</span><span class="hs-identifier">isInfixOf</span><span class="hs-special">`</span><span> </span><span class="hs-identifier">fn'</span><span> </span><span class="hs-operator">&amp;&amp;</span><span>
</span><span id="line-96"></span><span>            </span><span class="hs-string">&quot;-master&quot;</span><span> </span><span class="hs-special">`</span><span class="hs-identifier">isSuffixOf</span><span class="hs-special">`</span><span> </span><span class="hs-identifier">fn'</span><span>
</span><span id="line-97"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-98"></span><span>    </span><span class="hs-identifier">fn'</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">takeFileName</span><span> </span><span class="hs-identifier">fn</span><span>
</span><span id="line-99"></span><span class="hs-comment">-- Note that GetFileInformationByHandleEx might return a filepath like:</span><span>
</span><span id="line-100"></span><span class="hs-comment">--</span><span>
</span><span id="line-101"></span><span class="hs-comment">--    \msys-dd50a72ab4668b33-pty1-to-master</span><span>
</span><span id="line-102"></span><span class="hs-comment">--</span><span>
</span><span id="line-103"></span><span class="hs-comment">-- But NtQueryObject might return something like:</span><span>
</span><span id="line-104"></span><span class="hs-comment">--</span><span>
</span><span id="line-105"></span><span class="hs-comment">--    \Device\NamedPipe\msys-dd50a72ab4668b33-pty1-to-master</span><span>
</span><span id="line-106"></span><span class="hs-comment">--</span><span>
</span><span id="line-107"></span><span class="hs-comment">-- This means we can't rely on &quot;\cygwin-&quot; or &quot;\msys-&quot; being at the very start</span><span>
</span><span id="line-108"></span><span class="hs-comment">-- of the filepath. Therefore, we must take care to first call takeFileName</span><span>
</span><span id="line-109"></span><span class="hs-comment">-- before checking for &quot;cygwin&quot; or &quot;msys&quot; at the start using `isPrefixOf`.</span><span>
</span><span id="line-110"></span><span>
</span><span id="line-111"></span><span class="hs-identifier">getFileNameByHandle</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">HANDLE</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">String</span><span>
</span><span id="line-112"></span><span class="hs-identifier">getFileNameByHandle</span><span> </span><span class="hs-identifier">h</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-113"></span><span>  </span><span class="hs-keyword">let</span><span> </span><span class="hs-identifier">sizeOfDWORD</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">sizeOf</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">undefined</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">DWORD</span><span class="hs-special">)</span><span>
</span><span id="line-114"></span><span>      </span><span class="hs-comment">-- note: implicitly assuming that DWORD has stronger alignment than wchar_t</span><span>
</span><span id="line-115"></span><span>      </span><span class="hs-identifier">bufSize</span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">sizeOfDWORD</span><span> </span><span class="hs-operator">+</span><span> </span><span class="hs-identifier">mAX_PATH</span><span> </span><span class="hs-operator">*</span><span> </span><span class="hs-identifier">sizeOfTCHAR</span><span>
</span><span id="line-116"></span><span>  </span><span class="hs-identifier">allocaBytes</span><span> </span><span class="hs-identifier">bufSize</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-glyph">\</span><span class="hs-identifier">buf</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-117"></span><span>    </span><span class="hs-identifier">getFileInformationByHandleEx</span><span> </span><span class="hs-identifier">h</span><span> </span><span class="hs-identifier">fileNameInfo</span><span> </span><span class="hs-identifier">buf</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">fromIntegral</span><span> </span><span class="hs-identifier">bufSize</span><span class="hs-special">)</span><span>
</span><span id="line-118"></span><span>    </span><span class="hs-identifier">fni</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-identifier">peek</span><span> </span><span class="hs-identifier">buf</span><span>
</span><span id="line-119"></span><span>    </span><span class="hs-identifier">return</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">fniFileName</span><span> </span><span class="hs-identifier">fni</span><span>
</span><span id="line-120"></span><span>
</span><span id="line-121"></span><span class="hs-identifier">getFileInformationByHandleEx</span><span>
</span><span id="line-122"></span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">HANDLE</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">CInt</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Ptr</span><span> </span><span class="hs-identifier">FILE_NAME_INFO</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">DWORD</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-123"></span><span class="hs-identifier">getFileInformationByHandleEx</span><span> </span><span class="hs-identifier">h</span><span> </span><span class="hs-identifier">cls</span><span> </span><span class="hs-identifier">buf</span><span> </span><span class="hs-identifier">bufSize</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-124"></span><span>  </span><span class="hs-identifier">lib</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-identifier">getModuleHandle</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">Just</span><span> </span><span class="hs-string">&quot;kernel32.dll&quot;</span><span class="hs-special">)</span><span>
</span><span id="line-125"></span><span>  </span><span class="hs-identifier">ptr</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-identifier">getProcAddress</span><span> </span><span class="hs-identifier">lib</span><span> </span><span class="hs-string">&quot;GetFileInformationByHandleEx&quot;</span><span>
</span><span id="line-126"></span><span>  </span><span class="hs-keyword">let</span><span> </span><span class="hs-identifier">c_GetFileInformationByHandleEx</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-127"></span><span>        </span><span class="hs-identifier">mk_GetFileInformationByHandleEx</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">castPtrToFunPtr</span><span> </span><span class="hs-identifier">ptr</span><span class="hs-special">)</span><span>
</span><span id="line-128"></span><span>  </span><span class="hs-identifier">failIfFalse_</span><span> </span><span class="hs-string">&quot;getFileInformationByHandleEx&quot;</span><span>
</span><span id="line-129"></span><span>    </span><span class="hs-special">(</span><span class="hs-identifier">c_GetFileInformationByHandleEx</span><span> </span><span class="hs-identifier">h</span><span> </span><span class="hs-identifier">cls</span><span> </span><span class="hs-identifier">buf</span><span> </span><span class="hs-identifier">bufSize</span><span class="hs-special">)</span><span>
</span><span id="line-130"></span><span>
</span><span id="line-131"></span><span class="hs-identifier">ntQueryObjectNameInformation</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">HANDLE</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">String</span><span>
</span><span id="line-132"></span><span class="hs-identifier">ntQueryObjectNameInformation</span><span> </span><span class="hs-identifier">h</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-133"></span><span>  </span><span class="hs-keyword">let</span><span> </span><span class="hs-identifier">sizeOfONI</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">sizeOf</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">undefined</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">OBJECT_NAME_INFORMATION</span><span class="hs-special">)</span><span>
</span><span id="line-134"></span><span>      </span><span class="hs-identifier">bufSize</span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">sizeOfONI</span><span> </span><span class="hs-operator">+</span><span> </span><span class="hs-identifier">mAX_PATH</span><span> </span><span class="hs-operator">*</span><span> </span><span class="hs-identifier">sizeOfTCHAR</span><span>
</span><span id="line-135"></span><span>  </span><span class="hs-identifier">allocaBytes</span><span> </span><span class="hs-identifier">bufSize</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-glyph">\</span><span class="hs-identifier">buf</span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-136"></span><span>    </span><span class="hs-identifier">alloca</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-glyph">\</span><span class="hs-identifier">p_len</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-137"></span><span>      </span><span class="hs-identifier">hwnd</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-identifier">getModuleHandle</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">Just</span><span> </span><span class="hs-string">&quot;ntdll.exe&quot;</span><span class="hs-special">)</span><span>
</span><span id="line-138"></span><span>      </span><span class="hs-identifier">addr</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-identifier">getProcAddress</span><span> </span><span class="hs-identifier">hwnd</span><span> </span><span class="hs-string">&quot;NtQueryObject&quot;</span><span>
</span><span id="line-139"></span><span>      </span><span class="hs-keyword">let</span><span> </span><span class="hs-identifier">c_NtQueryObject</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">mk_NtQueryObject</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">castPtrToFunPtr</span><span> </span><span class="hs-identifier">addr</span><span class="hs-special">)</span><span>
</span><span id="line-140"></span><span>      </span><span class="hs-identifier">_</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-identifier">failIfNeg</span><span> </span><span class="hs-string">&quot;NtQueryObject&quot;</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">c_NtQueryObject</span><span>
</span><span id="line-141"></span><span>             </span><span class="hs-identifier">h</span><span> </span><span class="hs-identifier">objectNameInformation</span><span> </span><span class="hs-identifier">buf</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">fromIntegral</span><span> </span><span class="hs-identifier">bufSize</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">p_len</span><span>
</span><span id="line-142"></span><span>      </span><span class="hs-identifier">oni</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-identifier">peek</span><span> </span><span class="hs-identifier">buf</span><span>
</span><span id="line-143"></span><span>      </span><span class="hs-identifier">return</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">usBuffer</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">oniName</span><span> </span><span class="hs-identifier">oni</span><span>
</span><span id="line-144"></span><span>
</span><span id="line-145"></span><span class="hs-identifier">fileNameInfo</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">CInt</span><span>
</span><span id="line-146"></span><span class="hs-identifier">fileNameInfo</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-number">2</span><span>
</span><span id="line-147"></span><span class="hs-pragma">{-# LINE 147 &quot;libraries\\Win32\\System\\Win32\\MinTTY.hsc&quot; #-}</span><span>
</span><span id="line-147"></span><span>
</span><span id="line-148"></span><span class="hs-identifier">mAX_PATH</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">Num</span><span> </span><span class="hs-identifier">a</span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="hs-identifier">a</span><span>
</span><span id="line-149"></span><span class="hs-identifier">mAX_PATH</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-number">260</span><span>
</span><span id="line-150"></span><span class="hs-pragma">{-# LINE 150 &quot;libraries\\Win32\\System\\Win32\\MinTTY.hsc&quot; #-}</span><span>
</span><span id="line-150"></span><span>
</span><span id="line-151"></span><span class="hs-identifier">objectNameInformation</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">CInt</span><span>
</span><span id="line-152"></span><span class="hs-identifier">objectNameInformation</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-number">1</span><span>
</span><span id="line-153"></span><span class="hs-pragma">{-# LINE 153 &quot;libraries\\Win32\\System\\Win32\\MinTTY.hsc&quot; #-}</span><span>
</span><span id="line-153"></span><span>
</span><span id="line-154"></span><span class="hs-keyword">type</span><span> </span><span class="hs-identifier">F_NtQueryObject</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">HANDLE</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">CInt</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Ptr</span><span> </span><span class="hs-identifier">OBJECT_NAME_INFORMATION</span><span>
</span><span id="line-155"></span><span>                     </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">ULONG</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Ptr</span><span> </span><span class="hs-identifier">ULONG</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">NTSTATUS</span><span>
</span><span id="line-156"></span><span>
</span><span id="line-157"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-string">&quot;dynamic&quot;</span><span>
</span><span id="line-158"></span><span>  </span><span class="hs-identifier">mk_NtQueryObject</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">FunPtr</span><span> </span><span class="hs-identifier">F_NtQueryObject</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">F_NtQueryObject</span><span>
</span><span id="line-159"></span><span>
</span><span id="line-160"></span><span class="hs-keyword">type</span><span> </span><span class="hs-identifier">F_GetFileInformationByHandleEx</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-161"></span><span>  </span><span class="hs-identifier">HANDLE</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">CInt</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Ptr</span><span> </span><span class="hs-identifier">FILE_NAME_INFO</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">DWORD</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">BOOL</span><span>
</span><span id="line-162"></span><span>
</span><span id="line-163"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-string">&quot;dynamic&quot;</span><span>
</span><span id="line-164"></span><span>  </span><span class="hs-identifier">mk_GetFileInformationByHandleEx</span><span>
</span><span id="line-165"></span><span>    </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">FunPtr</span><span> </span><span class="hs-identifier">F_GetFileInformationByHandleEx</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">F_GetFileInformationByHandleEx</span><span>
</span><span id="line-166"></span><span>
</span><span id="line-167"></span><span class="hs-keyword">data</span><span> </span><span class="hs-identifier">FILE_NAME_INFO</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">FILE_NAME_INFO</span><span>
</span><span id="line-168"></span><span>  </span><span class="hs-special">{</span><span> </span><span class="hs-identifier">fniFileNameLength</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">DWORD</span><span>
</span><span id="line-169"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="hs-identifier">fniFileName</span><span>       </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">String</span><span>
</span><span id="line-170"></span><span>  </span><span class="hs-special">}</span><span> </span><span class="hs-keyword">deriving</span><span> </span><span class="hs-identifier">Show</span><span>
</span><span id="line-171"></span><span>
</span><span id="line-172"></span><span class="hs-keyword">instance</span><span> </span><span class="hs-identifier">Storable</span><span> </span><span class="hs-identifier">FILE_NAME_INFO</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-173"></span><span>    </span><span class="hs-identifier">sizeOf</span><span>    </span><span class="hs-identifier">_</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="hs-number">8</span><span class="hs-special">)</span><span>
</span><span id="line-174"></span><span class="hs-pragma">{-# LINE 174 &quot;libraries\\Win32\\System\\Win32\\MinTTY.hsc&quot; #-}</span><span>
</span><span id="line-174"></span><span>    </span><span class="hs-identifier">alignment</span><span> </span><span class="hs-identifier">_</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-number">4</span><span>
</span><span id="line-175"></span><span class="hs-pragma">{-# LINE 175 &quot;libraries\\Win32\\System\\Win32\\MinTTY.hsc&quot; #-}</span><span>
</span><span id="line-175"></span><span>    </span><span class="hs-identifier">poke</span><span> </span><span class="hs-identifier">buf</span><span> </span><span class="hs-identifier">fni</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">withTStringLen</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">fniFileName</span><span> </span><span class="hs-identifier">fni</span><span class="hs-special">)</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-glyph">\</span><span class="hs-special">(</span><span class="hs-identifier">str</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">len</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-176"></span><span>        </span><span class="hs-keyword">let</span><span> </span><span class="hs-identifier">len'</span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">min</span><span> </span><span class="hs-identifier">mAX_PATH</span><span> </span><span class="hs-identifier">len</span><span class="hs-special">)</span><span> </span><span class="hs-operator">*</span><span> </span><span class="hs-identifier">sizeOfTCHAR</span><span>
</span><span id="line-177"></span><span>            </span><span class="hs-identifier">start</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">advancePtr</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">castPtr</span><span> </span><span class="hs-identifier">buf</span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-number">4</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-178"></span><span class="hs-pragma">{-# LINE 178 &quot;libraries\\Win32\\System\\Win32\\MinTTY.hsc&quot; #-}</span><span>
</span><span id="line-178"></span><span>            </span><span class="hs-identifier">end</span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">advancePtr</span><span> </span><span class="hs-identifier">start</span><span> </span><span class="hs-identifier">len'</span><span>
</span><span id="line-179"></span><span>        </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">pokeByteOff</span><span> </span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-number">0</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">buf</span><span> </span><span class="hs-identifier">len'</span><span>
</span><span id="line-180"></span><span class="hs-pragma">{-# LINE 180 &quot;libraries\\Win32\\System\\Win32\\MinTTY.hsc&quot; #-}</span><span>
</span><span id="line-180"></span><span>        </span><span class="hs-identifier">copyArray</span><span> </span><span class="hs-identifier">start</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">castPtr</span><span> </span><span class="hs-identifier">str</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">Ptr</span><span> </span><span class="hs-identifier">Word8</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">len'</span><span>
</span><span id="line-181"></span><span>        </span><span class="hs-identifier">poke</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">castPtr</span><span> </span><span class="hs-identifier">end</span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="hs-number">0</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">TCHAR</span><span class="hs-special">)</span><span>
</span><span id="line-182"></span><span>    </span><span class="hs-identifier">peek</span><span> </span><span class="hs-identifier">buf</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-183"></span><span>        </span><span class="hs-identifier">vfniFileNameLength</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">peekByteOff</span><span> </span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-number">0</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">buf</span><span>
</span><span id="line-184"></span><span class="hs-pragma">{-# LINE 184 &quot;libraries\\Win32\\System\\Win32\\MinTTY.hsc&quot; #-}</span><span>
</span><span id="line-184"></span><span>        </span><span class="hs-keyword">let</span><span> </span><span class="hs-identifier">len</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">fromIntegral</span><span> </span><span class="hs-identifier">vfniFileNameLength</span><span> </span><span class="hs-special">`</span><span class="hs-identifier">div</span><span class="hs-special">`</span><span> </span><span class="hs-identifier">sizeOfTCHAR</span><span>
</span><span id="line-185"></span><span>        </span><span class="hs-identifier">vfniFileName</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-identifier">peekTStringLen</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">plusPtr</span><span> </span><span class="hs-identifier">buf</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-number">4</span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">len</span><span class="hs-special">)</span><span>
</span><span id="line-186"></span><span class="hs-pragma">{-# LINE 186 &quot;libraries\\Win32\\System\\Win32\\MinTTY.hsc&quot; #-}</span><span>
</span><span id="line-186"></span><span>        </span><span class="hs-identifier">return</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">FILE_NAME_INFO</span><span>
</span><span id="line-187"></span><span>          </span><span class="hs-special">{</span><span> </span><span class="hs-identifier">fniFileNameLength</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">vfniFileNameLength</span><span>
</span><span id="line-188"></span><span>          </span><span class="hs-special">,</span><span> </span><span class="hs-identifier">fniFileName</span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">vfniFileName</span><span>
</span><span id="line-189"></span><span>          </span><span class="hs-special">}</span><span>
</span><span id="line-190"></span><span>
</span><span id="line-191"></span><span class="hs-keyword">type</span><span> </span><span class="hs-identifier">NTSTATUS</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">Int32</span><span>
</span><span id="line-192"></span><span class="hs-pragma">{-# LINE 192 &quot;libraries\\Win32\\System\\Win32\\MinTTY.hsc&quot; #-}</span><span>
</span><span id="line-192"></span><span>
</span><span id="line-193"></span><span class="hs-keyword">newtype</span><span> </span><span class="hs-identifier">OBJECT_NAME_INFORMATION</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">OBJECT_NAME_INFORMATION</span><span>
</span><span id="line-194"></span><span>  </span><span class="hs-special">{</span><span> </span><span class="hs-identifier">oniName</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">UNICODE_STRING</span><span>
</span><span id="line-195"></span><span>  </span><span class="hs-special">}</span><span> </span><span class="hs-keyword">deriving</span><span> </span><span class="hs-identifier">Show</span><span>
</span><span id="line-196"></span><span>
</span><span id="line-197"></span><span class="hs-keyword">instance</span><span> </span><span class="hs-identifier">Storable</span><span> </span><span class="hs-identifier">OBJECT_NAME_INFORMATION</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-198"></span><span>    </span><span class="hs-identifier">sizeOf</span><span>    </span><span class="hs-identifier">_</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="hs-number">16</span><span class="hs-special">)</span><span>
</span><span id="line-199"></span><span class="hs-pragma">{-# LINE 199 &quot;libraries\\Win32\\System\\Win32\\MinTTY.hsc&quot; #-}</span><span>
</span><span id="line-199"></span><span>    </span><span class="hs-identifier">alignment</span><span> </span><span class="hs-identifier">_</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-number">8</span><span>
</span><span id="line-200"></span><span class="hs-pragma">{-# LINE 200 &quot;libraries\\Win32\\System\\Win32\\MinTTY.hsc&quot; #-}</span><span>
</span><span id="line-200"></span><span>    </span><span class="hs-identifier">poke</span><span> </span><span class="hs-identifier">buf</span><span> </span><span class="hs-identifier">oni</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">pokeByteOff</span><span> </span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-number">0</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">buf</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">oniName</span><span> </span><span class="hs-identifier">oni</span><span class="hs-special">)</span><span>
</span><span id="line-201"></span><span class="hs-pragma">{-# LINE 201 &quot;libraries\\Win32\\System\\Win32\\MinTTY.hsc&quot; #-}</span><span>
</span><span id="line-201"></span><span>    </span><span class="hs-identifier">peek</span><span> </span><span class="hs-identifier">buf</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">fmap</span><span> </span><span class="hs-identifier">OBJECT_NAME_INFORMATION</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">peekByteOff</span><span> </span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-number">0</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">buf</span><span>
</span><span id="line-202"></span><span class="hs-pragma">{-# LINE 202 &quot;libraries\\Win32\\System\\Win32\\MinTTY.hsc&quot; #-}</span><span>
</span><span id="line-202"></span><span>
</span><span id="line-203"></span><span class="hs-keyword">data</span><span> </span><span class="hs-identifier">UNICODE_STRING</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">UNICODE_STRING</span><span>
</span><span id="line-204"></span><span>  </span><span class="hs-special">{</span><span> </span><span class="hs-identifier">usLength</span><span>        </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">USHORT</span><span>
</span><span id="line-205"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="hs-identifier">usMaximumLength</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">USHORT</span><span>
</span><span id="line-206"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="hs-identifier">usBuffer</span><span>        </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">String</span><span>
</span><span id="line-207"></span><span>  </span><span class="hs-special">}</span><span> </span><span class="hs-keyword">deriving</span><span> </span><span class="hs-identifier">Show</span><span>
</span><span id="line-208"></span><span>
</span><span id="line-209"></span><span class="hs-keyword">instance</span><span> </span><span class="hs-identifier">Storable</span><span> </span><span class="hs-identifier">UNICODE_STRING</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-210"></span><span>    </span><span class="hs-identifier">sizeOf</span><span>    </span><span class="hs-identifier">_</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="hs-number">16</span><span class="hs-special">)</span><span>
</span><span id="line-211"></span><span class="hs-pragma">{-# LINE 211 &quot;libraries\\Win32\\System\\Win32\\MinTTY.hsc&quot; #-}</span><span>
</span><span id="line-211"></span><span>    </span><span class="hs-identifier">alignment</span><span> </span><span class="hs-identifier">_</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-number">8</span><span>
</span><span id="line-212"></span><span class="hs-pragma">{-# LINE 212 &quot;libraries\\Win32\\System\\Win32\\MinTTY.hsc&quot; #-}</span><span>
</span><span id="line-212"></span><span>    </span><span class="hs-identifier">poke</span><span> </span><span class="hs-identifier">buf</span><span> </span><span class="hs-identifier">us</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">withTStringLen</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">usBuffer</span><span> </span><span class="hs-identifier">us</span><span class="hs-special">)</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-glyph">\</span><span class="hs-special">(</span><span class="hs-identifier">str</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">len</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-213"></span><span>        </span><span class="hs-keyword">let</span><span> </span><span class="hs-identifier">len'</span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">min</span><span> </span><span class="hs-identifier">mAX_PATH</span><span> </span><span class="hs-identifier">len</span><span class="hs-special">)</span><span> </span><span class="hs-operator">*</span><span> </span><span class="hs-identifier">sizeOfTCHAR</span><span>
</span><span id="line-214"></span><span>            </span><span class="hs-identifier">start</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">advancePtr</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">castPtr</span><span> </span><span class="hs-identifier">buf</span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-number">16</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-215"></span><span class="hs-pragma">{-# LINE 215 &quot;libraries\\Win32\\System\\Win32\\MinTTY.hsc&quot; #-}</span><span>
</span><span id="line-215"></span><span>            </span><span class="hs-identifier">end</span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">advancePtr</span><span> </span><span class="hs-identifier">start</span><span> </span><span class="hs-identifier">len'</span><span>
</span><span id="line-216"></span><span>        </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">pokeByteOff</span><span> </span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-number">0</span><span class="hs-special">)</span><span class="hs-special">)</span><span>        </span><span class="hs-identifier">buf</span><span> </span><span class="hs-identifier">len'</span><span>
</span><span id="line-217"></span><span class="hs-pragma">{-# LINE 217 &quot;libraries\\Win32\\System\\Win32\\MinTTY.hsc&quot; #-}</span><span>
</span><span id="line-217"></span><span>        </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">pokeByteOff</span><span> </span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-number">2</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">buf</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">len'</span><span> </span><span class="hs-operator">+</span><span> </span><span class="hs-identifier">sizeOfTCHAR</span><span class="hs-special">)</span><span>
</span><span id="line-218"></span><span class="hs-pragma">{-# LINE 218 &quot;libraries\\Win32\\System\\Win32\\MinTTY.hsc&quot; #-}</span><span>
</span><span id="line-218"></span><span>        </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">pokeByteOff</span><span> </span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-number">8</span><span class="hs-special">)</span><span class="hs-special">)</span><span>        </span><span class="hs-identifier">buf</span><span> </span><span class="hs-identifier">start</span><span>
</span><span id="line-219"></span><span class="hs-pragma">{-# LINE 219 &quot;libraries\\Win32\\System\\Win32\\MinTTY.hsc&quot; #-}</span><span>
</span><span id="line-219"></span><span>        </span><span class="hs-identifier">copyArray</span><span> </span><span class="hs-identifier">start</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">castPtr</span><span> </span><span class="hs-identifier">str</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">Ptr</span><span> </span><span class="hs-identifier">Word8</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">len'</span><span>
</span><span id="line-220"></span><span>        </span><span class="hs-identifier">poke</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">castPtr</span><span> </span><span class="hs-identifier">end</span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="hs-number">0</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">TCHAR</span><span class="hs-special">)</span><span>
</span><span id="line-221"></span><span>    </span><span class="hs-identifier">peek</span><span> </span><span class="hs-identifier">buf</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-222"></span><span>        </span><span class="hs-identifier">vusLength</span><span>        </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">peekByteOff</span><span> </span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-number">0</span><span class="hs-special">)</span><span class="hs-special">)</span><span>        </span><span class="hs-identifier">buf</span><span>
</span><span id="line-223"></span><span class="hs-pragma">{-# LINE 223 &quot;libraries\\Win32\\System\\Win32\\MinTTY.hsc&quot; #-}</span><span>
</span><span id="line-223"></span><span>        </span><span class="hs-identifier">vusMaximumLength</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">peekByteOff</span><span> </span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-number">2</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">buf</span><span>
</span><span id="line-224"></span><span class="hs-pragma">{-# LINE 224 &quot;libraries\\Win32\\System\\Win32\\MinTTY.hsc&quot; #-}</span><span>
</span><span id="line-224"></span><span>        </span><span class="hs-identifier">vusBufferPtr</span><span>     </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">peekByteOff</span><span> </span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-number">8</span><span class="hs-special">)</span><span class="hs-special">)</span><span>        </span><span class="hs-identifier">buf</span><span>
</span><span id="line-225"></span><span class="hs-pragma">{-# LINE 225 &quot;libraries\\Win32\\System\\Win32\\MinTTY.hsc&quot; #-}</span><span>
</span><span id="line-225"></span><span>        </span><span class="hs-keyword">let</span><span> </span><span class="hs-identifier">len</span><span>          </span><span class="hs-glyph">=</span><span>  </span><span class="hs-identifier">fromIntegral</span><span> </span><span class="hs-identifier">vusLength</span><span> </span><span class="hs-special">`</span><span class="hs-identifier">div</span><span class="hs-special">`</span><span> </span><span class="hs-identifier">sizeOfTCHAR</span><span>
</span><span id="line-226"></span><span>        </span><span class="hs-identifier">vusBuffer</span><span>        </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-identifier">peekTStringLen</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">vusBufferPtr</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">len</span><span class="hs-special">)</span><span>
</span><span id="line-227"></span><span>        </span><span class="hs-identifier">return</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">UNICODE_STRING</span><span>
</span><span id="line-228"></span><span>          </span><span class="hs-special">{</span><span> </span><span class="hs-identifier">usLength</span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">vusLength</span><span>
</span><span id="line-229"></span><span>          </span><span class="hs-special">,</span><span> </span><span class="hs-identifier">usMaximumLength</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">vusMaximumLength</span><span>
</span><span id="line-230"></span><span>          </span><span class="hs-special">,</span><span> </span><span class="hs-identifier">usBuffer</span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">vusBuffer</span><span>
</span><span id="line-231"></span><span>          </span><span class="hs-special">}</span><span>
</span><span id="line-232"></span><span>
</span><span id="line-233"></span><span class="hs-identifier">sizeOfTCHAR</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">Int</span><span>
</span><span id="line-234"></span><span class="hs-identifier">sizeOfTCHAR</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">sizeOf</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">undefined</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">TCHAR</span><span class="hs-special">)</span><span>
</span><span id="line-235"></span></pre></body></html>